package org.dftproject.genesis.ui.figures;

import org.dftproject.genesis.ui.pages.home.TraversablePanel;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.MarginBorder;
import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Color;

public class PageContainer extends TraversablePanel {
	
	private final Color gradientTop = new Color(null, 234, 244, 255);
	private final Color gradientBottom = ColorConstants.white;
	
	public PageContainer() {
		setBackgroundColor(gradientBottom);
		
		ToolbarLayout layout = new ToolbarLayout(false);
		layout.setSpacing(5);
		layout.setStretchMinorAxis(false);
		setLayoutManager(layout);
		
		setBorder(new MarginBorder(20));
	}
	
	@Override
	public void paintFigure(Graphics graphics) {
		super.paintFigure(graphics);
		
		Rectangle gradientRect = getBounds().getCopy();
		gradientRect.height = 64;
		
		graphics.pushState();
		graphics.setForegroundColor(gradientTop);
		graphics.setBackgroundColor(gradientBottom);
		graphics.fillGradient(gradientRect, true);
		graphics.popState();
	}
	
}
